<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Calculate the metaphone key of a string</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.md5.html">md5</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.money-format.html">money_format</a></div>
 <div class="up"><a href="ref.strings.html">字符串函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.metaphone" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">metaphone</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">metaphone</span> &mdash; <span class="dc-title">Calculate the metaphone key of a string</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.metaphone-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>metaphone</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$phonemes</code><span class="initializer"> = 0</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Calculates the metaphone key of <em><code class="parameter">str</code></em>.
  </p>
  <p class="para">
   Similar to <span class="function"><a href="function.soundex.html" class="function">soundex()</a></span> metaphone creates the same key for
   similar sounding words. It&#039;s more accurate than
   <span class="function"><a href="function.soundex.html" class="function">soundex()</a></span> as it knows the basic rules of English
   pronunciation.  The metaphone generated keys are of variable length.
  </p>
  <p class="para">
   Metaphone was developed by Lawrence Philips
   &lt;lphilips at verity dot com&gt;. It is described in [&quot;Practical
   Algorithms for Programmers&quot;, Binstock &amp; Rex, Addison Wesley,
   1995].
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.metaphone-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">str</code></em></dt>

     <dd>

      <p class="para">
       The input string.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">phonemes</code></em></dt>

     <dd>

      <p class="para">
       This parameter restricts the returned metaphone key to 
       <em><code class="parameter">phonemes</code></em> characters in length.
       The default value of <em>0</em> means no restriction.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.metaphone-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the metaphone key as a string,  或者在失败时返回 <strong><code>FALSE</code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.metaphone-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="metaphone.example.basic">
    <p><strong>Example #1 <span class="function"><strong>metaphone()</strong></span> basic example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">metaphone</span><span style="color: #007700">(</span><span style="color: #DD0000">'programming'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">metaphone</span><span style="color: #007700">(</span><span style="color: #DD0000">'programmer'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(7) &quot;PRKRMNK&quot;
string(6) &quot;PRKRMR&quot;
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="metaphone.example.phonemes">
    <p><strong>Example #2 Using the <em><code class="parameter">phonemes</code></em> parameter</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">metaphone</span><span style="color: #007700">(</span><span style="color: #DD0000">'programming'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">metaphone</span><span style="color: #007700">(</span><span style="color: #DD0000">'programmer'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(5) &quot;PRKRM&quot;
string(5) &quot;PRKRM&quot;
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.md5.html">md5</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.money-format.html">money_format</a></div>
 <div class="up"><a href="ref.strings.html">字符串函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
